package com.easybuy.daoimpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.easybuy.dao.SortDao;
import com.easybuy.entily.Product_category;

public class SortDaoImpl extends com.easybuy.dao.BaseDao implements SortDao{

	@Override
	public List<Product_category> getAllProductCategory(int parentId) {
		Connection conn=null;	//��������
		PreparedStatement pstmt=null; //����PreparedStatement����
		ResultSet rs=null;	//����ResultSet����
		List<Product_category> list=new ArrayList<Product_category>(); //������ݼ�
		Product_category epc; //���������
		try {
			conn=this.getConnection(); 
			String sql="select * from easyBuy_product_category where parentId=?"; //SQL���
			pstmt=conn.prepareStatement(sql);//����SQL���ķ���
			pstmt.setInt(1, parentId);
			rs=pstmt.executeQuery();
			while(rs.next()){
				epc=new Product_category();
				epc.setId(rs.getInt("id"));
				epc.setName(rs.getString("name"));
				epc.setParentId(rs.getInt("parentId"));
				epc.setType(rs.getInt("type"));
				epc.setIconClass(rs.getString("iconClass"));
				list.add(epc);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			closeAll(conn, pstmt, rs);//�ر�����
		}
		return list; //�������
	}

}
